package com.example.common.widget.state;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public abstract class BaseStateView implements NetworkStateLayout.NetworkState {

    private ViewGroup parentView;
    private View mStateView;

    @Override
    public View getNetworkStateView() {
        return mStateView;
    }

    @Override
    public void bindParentView(NetworkStateLayout parentView) {
        this.parentView = parentView;

        mStateView = LayoutInflater.from(parentView.getContext()).inflate(
                getLayoutId(), parentView, false);

        parentView.addView(mStateView);
    }

    @Override
    public void showView(CharSequence message) {
        for (int i = 0; i < parentView.getChildCount(); i++)
            parentView.getChildAt(i).setVisibility(View.GONE);

        mStateView.setVisibility(View.VISIBLE);
    }

    @Override
    public void setOnAnewRequestNetworkListener(
            OnAnewRequestNetworkListener onAnewRequestNetworkListener) {

    }

    public abstract int getLayoutId();
}
